import './assets/main.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia';
import App from './App.vue'
import router from './router'
import 'element-plus/dist/index.css';
import {getCurrRoutes} from "@/grants/routes";
import {useUserStore} from "@/stores/grantsStore";
import  Editor  from "@tinymce/tinymce-vue";
import {useBreadcrumbStore} from "@/stores/breadcrumb";


const app = createApp(App)

app.use(Editor);
app.use(createPinia());

const userStore = useUserStore();

if(userStore.isLogin){
    console.log("main.ts里调用了getCurrRoutes()");
    getCurrRoutes();//动态添加当前用户的路由配置。
}

app.use(router);

const {changeBreadcrumb} = useBreadcrumbStore();

router.afterEach((to,from)=>{

  console.log("to",to);
  // if(路径中是以/Admin开头){
    changeBreadcrumb(to.path,to.meta.titles as string[]);
  // }
})


app.mount('#app')
